package cn.edu.zut.business;

import cn.edu.zut.dao.StudentDao;
import cn.edu.zut.model.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class AverageService {
    StudentDao studentDao;
    public float OnAverageService(){
        List<Student> students=studentDao.queryAll();
        float numGrade=0;
        for(Student s:students){
            numGrade+=s.getGrade();
        }
        return numGrade/students.size();
    }
    @Autowired
    public void setStudentDao(StudentDao studentDao) {
        this.studentDao = studentDao;
    }
}
